<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/includes/directives/page.jspf"%>
<%@ include file="/WEB-INF/views/includes/directives/taglib.jspf"%>

<c:choose>

	<c:when test="${empty ordersList}">
		<div>
			<fmt:message key="orders_list_jsp.label.empty_list" />
		</div>
	</c:when>
	<c:otherwise>
		<table>
			<tr>
				<td>id</td>
				<td><fmt:message key="orders_list_jsp.table.header.order_date" /></td>
				<td><fmt:message
						key="orders_list_jsp.table.header.order_status" /></td>
				<td></td>
			</tr>
			<c:forEach var="order" items="${ordersList}">
				<tr>
					<td>${order.orderId}</td>
					<td><fmt:formatDate value="${order.orderDate}" type="both" /></td>
					<td><c:choose>
							<c:when test="${order.status eq 'ORDERED'}">
								<fmt:message key="orders_list_jsp.table.status.ordered" />
							</c:when>
							<c:when test="${order.status eq 'PAID'}">
								<fmt:message key="orders_list_jsp.table.status.paid" />
							</c:when>
							<c:when test="${order.status eq 'SHIPPED'}">
								<fmt:message key="orders_list_jsp.table.status.shipped" />
							</c:when>
							<c:when test="${order.status eq 'DELIVERED'}">
								<fmt:message key="orders_list_jsp.table.status.delivered" />
							</c:when>
						</c:choose></td>
					<c:if test="${order.status eq 'ORDERED'}">
						<td><a onclick="payForOrder(${order.orderId});" href="#">
								<fmt:message key="orders_list_jsp.label.pay" />
						</a></td>
					</c:if>
				</tr>
			</c:forEach>
		</table>
	</c:otherwise>
</c:choose>